<template>
  <div class="talk">
    <button @click="getTalk">获取内容</button>
    <ul>
      <li v-for="item in talkList" :key="item.id">{{ item.title }}</li>
    </ul>
  </div>
</template>
  <script setup lang='ts'>
import { useLoveTalkStore } from "@/store/loveTalk";
import { storeToRefs } from "pinia";
import { log } from "console";
const talkStore = useLoveTalkStore()
// console.log("@@@@==",talkStore);
console.log("@@@@talkStore==",talkStore.talkList);
const {talkList} = storeToRefs(talkStore)
talkStore.$subscribe((mutate,state)=>{
    console.log("talkStore发生了变化",mutate,state);
    sessionStorage.setItem("talkList",JSON.stringify(state.talkList))
    
})
async function getTalk() {
    talkStore.getAtalk()
}
</script>
  <style scoped>
.talk {
  background-color: orange;
  padding: 10px;
  border-radius: 10px;
  box-shadow: 0 0 10px;
}
select,
button {
  margin: 0 5px;
  height: 25px;
}
</style>